﻿@{
    Layout = "_FinanceLayout";
}
    <fieldset class="layui-elem-field" style="margin: 20px">
        <legend>物资申请信息</legend>
        <div class="layui-field-box">
                <table class="layui-hide" id="mtable" lay-filter="mtable"></table>
        </div>
    </fieldset>
@section Scripts{ 
    <script src="~/layui-v2.5.5/layui/layui.js" charset="utf-8"></script>
    <script>
        function statetostring(stateint)
        {
            switch(stateint) {
                case 0:
                    return "<span style='color:red'>未审核</span>";
                break;
                case 1:
                    return "<span style='color:green'>同意</span>";
                    break;
                case 2:
                    return "<span style='color:gray'>拒绝</span>";
                    break;
                break;
                default:
                break;
            }
        }

        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#mtable'
                , url: '/api/QueryMaterialApplication?state=3'
                , toolbar: false
                , title: 'Material Table'
                , cols: [[
                    { field: 'id', title: 'ID', fixed: 'left', width: '5%', sort: true }
                    , { field: 'departmentid', title: '部门名称', sort: true }
                    , { field: 'tid', title: '教师名称', sort: true }
                    , { field: 'goodsname', title: '物资名称' }
                    , { field: 'goodsnum', title: '物资数量' }
                    , { field: 'remarks', title: '采购原因' }
                    , {field: 'state', title: '申请状态'
                    , templet: function (d) {
                         return statetostring(d.state)
                     }                    
                    }
                ]]
                , page: true
            });
         
            
            //监听行单击事件
            table.on('row(mtable)', function(obj){
                layui.use('layer', function () {
                    var layer = layui.layer;
                    layer.open({
                        type: 2,
                        title: false,
                        closeBtn: 1, //显示关闭按钮
                        shade: [0],
                        area: ['300px', '500px'],
                        offset: 'auto',
                        anim: 2,
                        content: ['/CWC/MaterialDetail?id='+obj.data.id, 'no'], //iframe的url，no代表不显示滚动条
                    });
                });
            });

        });
    </script>
}